package edu.ped.android.utils;

import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.io.Serializable;
import java.io.StreamCorruptedException;

public class Rule implements Serializable{
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	private Action action;
	private GestureNFC gesture;
	private String description;
	private String name;
	private int height;
	private int width;
	
	public Rule(Action action, GestureNFC gesture, String description, String name,int height,int width) {
		super();
		this.action = action;
		this.gesture = gesture;
		this.description = description;
		this.height=height;
		this.width=width;
		this.name = name;
	}
	
	public Rule(byte[] blob) throws StreamCorruptedException, IOException, ClassNotFoundException {
		ByteArrayInputStream b = new ByteArrayInputStream(blob);
		ObjectInputStream in = new ObjectInputStream(b);
		Rule r = ((Rule) in.readObject());
		action=r.getAction();
		gesture=r.getGesture();
		description=r.getDescription();
		name=r.getName();
		height=r.getHeight();
		width=r.getWidth();
	}

	public byte[] toByteArray() throws IOException{
		ByteArrayOutputStream b = new ByteArrayOutputStream();
		ObjectOutputStream in = new ObjectOutputStream(b);
		in.writeObject(this);
		return b.toByteArray();
	}

	
	public Action getAction() {
		return action;
	}
	public void setAction(Action action) {
		this.action = action;
	}
	public GestureNFC getGesture() {
		return gesture;
	}
	public void setGesture(GestureNFC gesture) {
		this.gesture = gesture;
	}
	public String getDescription() {
		return description;
	}
	public void setDescription(String description) {
		this.description = description;
	}
	public String getName() {
		return name;
	}
	public void setName(String name) {
		this.name = name;
	}
	public int getHeight() {
		return height;
	}
	public void setHeight(int height) {
		this.height = height;
	}
	public int getWidth() {
		return width;
	}
	public void setWidth(int width) {
		this.width = width;
	}
	
	
	
}
